package org.dregs.pojo;

import org.dregs.pojo.tuple.Tuple;
import org.dregs.pojo.tuple.Tuple2;
import org.dregs.utils.BuildMap;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

public class FileType extends DataBean implements Serializable {

    private Long id;

    private String fileID;

    private String fileName;

    private String description;

    public FileType(Long id, String fileID, String fileName, String description) {
        this.id = id;
        this.fileID = fileID;
        this.fileName = fileName;
        this.description = description;
    }

    public FileType() {
    }
    public FileType(ResultSet resultSet) throws SQLException {
        this.id = resultSet.getLong("id");
        this.fileID = resultSet.getString("file_id");
        this.fileName = resultSet.getString("file_name");
        this.description = resultSet.getString("description");
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFileID() {
        return fileID;
    }

    public void setFileID(String fileID) {
        this.fileID = fileID;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Tuple2<String,Long> id() {
        return Tuple.initialize("`id`",id);
    }

    public Tuple2<String,String> file_id() {
        return Tuple.initialize("`file_id`",fileID);
    }

    public Tuple2<String,String> file_name() {
        return Tuple.initialize("`file_name`",fileName);
    }

    public Tuple2<String,String> desc() {
        return Tuple.initialize("`desc`",description);
    }


    @Override
    public Map<String,Object> toMap(){
        BuildMap<String, Object> buildMap = new BuildMap<>();
        if(null != id)
            buildMap.put("`id`",id);
        if(null != fileID)
            buildMap.put("`file_id`",fileID);
        if(null != fileName)
            buildMap.put("`file_name`",fileName);
        if(null != description)
            buildMap.put("`desc`",description);
        return buildMap.toMap();
    }
}
